package io.qar.orders.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.qar.commons.mybatis.service.impl.CrudServiceImpl;
import io.qar.orders.dao.OrdersDao;
import io.qar.orders.dto.OrdersDTO;
import io.qar.orders.entity.OrdersEntity;
import io.qar.orders.service.OrdersService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 订单表
 *
 * @author yyyyjinying 1020066395@qq.com
 * @since 3.0 2024-06-11
 */
@Service
public class OrdersServiceImpl extends CrudServiceImpl<OrdersDao, OrdersEntity, OrdersDTO> implements OrdersService {

    @Override
    public QueryWrapper<OrdersEntity> getWrapper(Map<String, Object> params){
        QueryWrapper<OrdersEntity> wrapper = new QueryWrapper<>();

        String startDateTime = (String)params.get("startDateTime");
        String endDateTime = (String)params.get("endDateTime");
        wrapper.ge(StringUtils.isNotBlank(startDateTime), "order_time", startDateTime);
        wrapper.le(StringUtils.isNotBlank(endDateTime), "order_time", endDateTime);
//        String startDateTime = (String)params.get("startDateTime");
//        String endDateTime = (String)params.get("endDateTime");
//        wrapper.ge(StringUtils.isNotBlank(startDateTime), "checkout_time", startDateTime);
//        wrapper.le(StringUtils.isNotBlank(endDateTime), "checkout_time", endDateTime);
        String payMethod = (String)params.get("payMethod");
        wrapper.eq(StringUtils.isNotBlank(payMethod), "pay_method", payMethod);
        String payStatus = (String)params.get("payStatus");
        wrapper.eq(StringUtils.isNotBlank(payStatus), "pay_status", payStatus);

        return wrapper;
    }


}